package com.mycompany.tpfinal.abm;

import java.sql.Array;
import java.sql.Blob;
import java.sql.CallableStatement;
import java.sql.Clob;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.NClob;
import java.sql.PreparedStatement;
import java.sql.SQLClientInfoException;
import java.sql.SQLException;
import java.sql.SQLWarning;
import java.sql.SQLXML;
import java.sql.Savepoint;
import java.sql.Statement;
import java.sql.Struct;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.Executor;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableRowSorter;

/**
 *
 * @author Pablo Capozzi
 */
public class PeliculaViewSwing extends javax.swing.JFrame  {
    public ControladorABM controladorABM;
    public List<Pelicula> lista;
    public Pelicula pelicula; 
    
            
    DefaultTableModel model;
    
        
   //Valor para manejar las opciones
    public boolean opcion = true;
           
    //Constructor
    public PeliculaViewSwing() throws Exception {
        initComponents();
        TxtGenero.setEnabled(false);
        this.setTitle("VideoClub-ABM");
        controladorABM = new ControladorABM();
        lista = new ArrayList<Pelicula>();
    
        cargarPelicula("");
        
    }
       
    //Métodos
    
    //Carga las peliculas de la base de datos en la JTable de la interfaz   
    public void cargarPelicula(String valor) throws Exception{
                       
        String[] titulos = {"ID","NAME","DESCRIPTION","GENRE_ID","DIRECTOR","MAIN_ACTORS","DURATION"};
        model = new DefaultTableModel(null,titulos);
        String[] fila = new String[7];
        
        lista = controladorABM.generaLista(valor);
        
        if(!lista.isEmpty()){
            for(Pelicula p: lista){
                    fila[0] = String.valueOf(p.getId());
                    fila[1] = p.getNombre();
                    fila[2] = p.getDescripcion();
                    fila[3] = p.getGenero();
                    fila[4] = p.getDirector();
                    fila[5] = p.getActorPrincipal();
                    fila[6] = String.valueOf(p.getDuracion());
            
                    model.addRow(fila);
            
            }
            Tabla.setModel(model);
            TableRowSorter<DefaultTableModel> ordena = new TableRowSorter<DefaultTableModel>(model);
            Tabla.setRowSorter(ordena);
            
            
            
        }   
        else{
                            
                
                JOptionPane.showMessageDialog(null, "No hay películas cargadas en la base de datos"); 
                
                
                    
            }
    }
    
    public void obtenerDatosFormulario(){
        pelicula = new Pelicula();
        pelicula.setNombre(TxtNombre.getText());
        pelicula.setDescripcion(TxtDescripcion.getText());
        pelicula.setGenero(TxtGenero.getText());
        pelicula.setDirector(TxtDirector.getText());
        pelicula.setActorPrincipal(TxtActorPrincipal.getText());
        pelicula.setDuracion(Integer.parseInt(TxtDuracion.getText()));
           
    }
    
    public void modificarDatosFormulario(){
        pelicula = new Pelicula();
        pelicula.setId(Integer.parseInt(LabelCodigo.getText()));
        pelicula.setNombre(TxtNombre.getText());
        pelicula.setDescripcion(TxtDescripcion.getText());
        pelicula.setGenero(TxtGenero.getText());
        pelicula.setDirector(TxtDirector.getText());
        pelicula.setActorPrincipal(TxtActorPrincipal.getText());
        pelicula.setDuracion(Integer.parseInt(TxtDuracion.getText()));
    }
        
    public void insertarPelicula() throws Exception{
        String respuesta;
        obtenerDatosFormulario();
        respuesta = controladorABM.generaAlta(pelicula);
        
        if(respuesta == null){
            JOptionPane.showMessageDialog(null, "La pelicula se ingresó correctamente");
        }
        else{
            JOptionPane.showMessageDialog(null, "Error al ingresar la pelicula" + respuesta);
        }
    }
     
    public void codPelicula(){
        Integer id = controladorABM.idPelicula();
        LabelCodigo.setText(String.valueOf(id));
    }
    
    public void buscarPelicula(Integer id){
        pelicula = controladorABM.get(id);
        
        if(pelicula.getId()!= 0){
            LabelCodigo.setText(String.valueOf(pelicula.getId()));
            TxtNombre.setText(String.valueOf(pelicula.getNombre()));
            TxtGenero.setText(String.valueOf(pelicula.getGenero()));
            TxtDescripcion.setText(String.valueOf(pelicula.getDescripcion()));
            TxtDirector.setText(String.valueOf(pelicula.getDirector()));
            TxtActorPrincipal.setText(String.valueOf(pelicula.getActorPrincipal()));
            TxtDuracion.setText(String.valueOf(pelicula.getDuracion()));
        }else{
            JOptionPane.showMessageDialog(null, "Pelicula no encontrada");
        }        
        
    }
      
    
    public void actualizarPelicula() throws Exception{
        modificarDatosFormulario();
        String respuesta = controladorABM.generaModificacion(pelicula);
        
        if(respuesta != null){
            JOptionPane.showMessageDialog(null, "Error al actualizar" + respuesta);
        }
        else{
            JOptionPane.showMessageDialog(null, "La pelicula se actualizó correctamente");
        }
   }    
   
    public void eliminarPelicula() throws Exception{
        Integer id = Integer.parseInt(LabelCodigo.getText());
        
        
        String respuesta = controladorABM.generaBaja(id);
        
        if(respuesta == null){
            JOptionPane.showMessageDialog(null, "Pelicula eliminada");
        }
        else{
            JOptionPane.showMessageDialog(null, "Error: la pelicula no se pudo eliminar" + respuesta);
        }
    }
        
    public void limpiaDatosFormulario(){
        LabelCodigo.setText(null);
        TxtNombre.setText(null);
        TxtGenero.setText(null);
        TxtDescripcion.setText(null);
        TxtDirector.setText(null);
        TxtActorPrincipal.setText(null);
        TxtDuracion.setText(null);
    }
    
    
    
    
    
    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        Tabla = new javax.swing.JTable();
        Grabar = new javax.swing.JButton();
        Eliminar = new javax.swing.JButton();
        Modificar = new javax.swing.JButton();
        Panel = new javax.swing.JPanel();
        Nombre = new javax.swing.JLabel();
        Descripcion = new javax.swing.JLabel();
        Genero = new javax.swing.JLabel();
        Director = new javax.swing.JLabel();
        ActorPrincipal = new javax.swing.JLabel();
        Duracion = new javax.swing.JLabel();
        TxtNombre = new javax.swing.JTextField();
        TxtDescripcion = new javax.swing.JTextField();
        TxtGenero = new javax.swing.JTextField();
        TxtDirector = new javax.swing.JTextField();
        TxtActorPrincipal = new javax.swing.JTextField();
        TxtDuracion = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        Buscar = new javax.swing.JButton();
        LabelCodigo = new javax.swing.JLabel();
        Combo = new javax.swing.JComboBox();
        jLabel2 = new javax.swing.JLabel();
        Limpiar = new javax.swing.JToggleButton();
        Salir = new javax.swing.JToggleButton();
        Filtrar = new javax.swing.JLabel();
        TxtFiltrar = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        Tabla.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "ID", "NAME", "DESCRIPTION", "GENRE_ID", "DIRECTOR", "MAIN_ACTORS", "DURATION"
            }
        ));
        jScrollPane1.setViewportView(Tabla);

        Grabar.setText("Grabar");
        Grabar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                GrabarActionPerformed(evt);
            }
        });

        Eliminar.setText("Eliminar");
        Eliminar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                EliminarActionPerformed(evt);
            }
        });

        Modificar.setText("Modificar");
        Modificar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ModificarActionPerformed(evt);
            }
        });

        Panel.setBorder(javax.swing.BorderFactory.createTitledBorder("Datos de la pelicula"));

        Nombre.setText("Nombre");

        Descripcion.setText("Descripcion");

        Genero.setText("Genero");

        Director.setText("Director");

        ActorPrincipal.setText("ActorPrincipal");

        Duracion.setText("Duracion");

        TxtDuracion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                TxtDuracionActionPerformed(evt);
            }
        });

        jLabel1.setText("Código de la Película");

        Buscar.setText("Buscar");
        Buscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BuscarActionPerformed(evt);
            }
        });

        Combo.setEditable(true);
        Combo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Drama", "Suspenso", "Accion", "Comedia", "Terror", "Otro" }));
        Combo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ComboActionPerformed(evt);
            }
        });

        jLabel2.setText("Presione ENTER para validar los datos");

        javax.swing.GroupLayout PanelLayout = new javax.swing.GroupLayout(Panel);
        Panel.setLayout(PanelLayout);
        PanelLayout.setHorizontalGroup(
            PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(Director)
                    .addComponent(Genero)
                    .addComponent(Descripcion)
                    .addComponent(ActorPrincipal)
                    .addComponent(Duracion)
                    .addComponent(Nombre))
                .addGap(13, 13, 13)
                .addGroup(PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(PanelLayout.createSequentialGroup()
                        .addGroup(PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(PanelLayout.createSequentialGroup()
                                .addGroup(PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(TxtGenero, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE)
                                    .addComponent(TxtDescripcion)
                                    .addComponent(TxtDirector)
                                    .addComponent(TxtActorPrincipal)
                                    .addComponent(TxtDuracion))
                                .addGap(38, 38, 38)
                                .addComponent(Combo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(TxtNombre, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(244, 244, 244)
                        .addGroup(PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(PanelLayout.createSequentialGroup()
                                .addComponent(jLabel1)
                                .addGap(18, 18, 18)
                                .addComponent(LabelCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(Buscar, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 221, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(79, Short.MAX_VALUE))
        );
        PanelLayout.setVerticalGroup(
            PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Nombre)
                    .addComponent(TxtNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1)
                    .addComponent(LabelCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(PanelLayout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(Buscar))
                    .addGroup(PanelLayout.createSequentialGroup()
                        .addGap(5, 5, 5)
                        .addGroup(PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(TxtDescripcion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(Descripcion))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(TxtGenero, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(Genero)
                            .addComponent(Combo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(TxtDirector, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(Director))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(TxtActorPrincipal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(ActorPrincipal))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(PanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(TxtDuracion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(Duracion))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        Limpiar.setText("Limpiar");
        Limpiar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                LimpiarActionPerformed(evt);
            }
        });

        Salir.setText("Salir");
        Salir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SalirActionPerformed(evt);
            }
        });

        Filtrar.setText("Filtrar");

        TxtFiltrar.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                TxtFiltrarKeyReleased(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(Panel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(27, 27, 27)
                        .addComponent(Grabar)
                        .addGap(18, 18, 18)
                        .addComponent(Modificar)
                        .addGap(18, 18, 18)
                        .addComponent(Eliminar)
                        .addGap(18, 18, 18)
                        .addComponent(Limpiar)
                        .addGap(18, 18, 18)
                        .addComponent(Salir, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 603, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(25, 25, 25)
                        .addComponent(Filtrar, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(TxtFiltrar, javax.swing.GroupLayout.PREFERRED_SIZE, 169, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(0, 0, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(Panel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(26, 26, 26)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Filtrar)
                    .addComponent(TxtFiltrar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Grabar)
                    .addComponent(Modificar)
                    .addComponent(Eliminar)
                    .addComponent(Limpiar)
                    .addComponent(Salir))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void GrabarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_GrabarActionPerformed
       try {
            insertarPelicula();
            limpiaDatosFormulario();
        } catch (Exception ex) {
            Logger.getLogger(PeliculaViewSwing.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
            cargarPelicula("");
        } catch (Exception ex) {
            Logger.getLogger(PeliculaViewSwing.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_GrabarActionPerformed

    private void EliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_EliminarActionPerformed
      try {
            eliminarPelicula();
            limpiaDatosFormulario();
        } catch (Exception ex) {
            Logger.getLogger(PeliculaViewSwing.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
            cargarPelicula("");
        } catch (Exception ex) {
            Logger.getLogger(PeliculaViewSwing.class.getName()).log(Level.SEVERE, null, ex);
        }
        
    }//GEN-LAST:event_EliminarActionPerformed

    private void ModificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ModificarActionPerformed
        try {
            actualizarPelicula();
            limpiaDatosFormulario();
            
        } catch (Exception ex) {
            Logger.getLogger(PeliculaViewSwing.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
            cargarPelicula("");
        } catch (Exception ex) {
            Logger.getLogger(PeliculaViewSwing.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_ModificarActionPerformed

    private void LimpiarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LimpiarActionPerformed
        LabelCodigo.setText(null);
        TxtNombre.setText(null);
        TxtDescripcion.setText(null);
        TxtGenero.setText(null);
        TxtDirector.setText(null);
        TxtActorPrincipal.setText(null);
        TxtDuracion.setText(null);
    
    }//GEN-LAST:event_LimpiarActionPerformed

    private void SalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SalirActionPerformed
        System.exit(0);
    }//GEN-LAST:event_SalirActionPerformed

    private void ComboActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ComboActionPerformed
        String opcion = new String();

        opcion = (String) Combo.getSelectedItem();

        if(opcion.equals("Otro")){
            TxtGenero.setEnabled(true);
            TxtGenero.setEditable(true);
            TxtGenero.setText("Ingrese un nuevo Género...");
        }
        else{
            TxtGenero.setText((String) Combo.getSelectedItem());
        }

    }//GEN-LAST:event_ComboActionPerformed

    private void BuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BuscarActionPerformed
        Integer id = Integer.valueOf(JOptionPane.showInputDialog("Ingrese el código de la pelicula"));
        buscarPelicula(id);
    }//GEN-LAST:event_BuscarActionPerformed

    private void TxtDuracionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TxtDuracionActionPerformed
        String duracion = new String();
        
        duracion = TxtDuracion.getText();
        
        if (duracion.equals("0")){
            JOptionPane.showMessageDialog(null, "La duración debe ser mayor a cero. Ingrese nuevamente la duración de la película");
            TxtDuracion.requestFocus();
        }
        else{
            JOptionPane.showMessageDialog(null, "Datos validados correctamente");
        }
        
    }//GEN-LAST:event_TxtDuracionActionPerformed

    private void TxtFiltrarKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_TxtFiltrarKeyReleased
        String auxFiltrar = TxtFiltrar.getText();
        
        try {
            cargarPelicula(auxFiltrar);
        } catch (Exception ex) {
            Logger.getLogger(PeliculaViewSwing.class.getName()).log(Level.SEVERE, null, ex);
        }
        
    }//GEN-LAST:event_TxtFiltrarKeyReleased

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(PeliculaViewSwing.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(PeliculaViewSwing.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(PeliculaViewSwing.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(PeliculaViewSwing.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    new PeliculaViewSwing().setVisible(true);
                } catch (Exception ex) {
                    Logger.getLogger(PeliculaViewSwing.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        });
    }

    
    
    
    
    
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel ActorPrincipal;
    private javax.swing.JButton Buscar;
    private javax.swing.JComboBox Combo;
    private javax.swing.JLabel Descripcion;
    private javax.swing.JLabel Director;
    private javax.swing.JLabel Duracion;
    private javax.swing.JButton Eliminar;
    private javax.swing.JLabel Filtrar;
    private javax.swing.JLabel Genero;
    private javax.swing.JButton Grabar;
    private javax.swing.JLabel LabelCodigo;
    private javax.swing.JToggleButton Limpiar;
    private javax.swing.JButton Modificar;
    private javax.swing.JLabel Nombre;
    private javax.swing.JPanel Panel;
    private javax.swing.JToggleButton Salir;
    private javax.swing.JTable Tabla;
    private javax.swing.JTextField TxtActorPrincipal;
    private javax.swing.JTextField TxtDescripcion;
    private javax.swing.JTextField TxtDirector;
    private javax.swing.JTextField TxtDuracion;
    private javax.swing.JTextField TxtFiltrar;
    private javax.swing.JTextField TxtGenero;
    private javax.swing.JTextField TxtNombre;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JScrollPane jScrollPane1;
    // End of variables declaration//GEN-END:variables

   

    
    
    
    
    
   
}